package com.example.yuntiku.Service;

import com.example.yuntiku.dao.impl.CurriculumDaoImpl;
import com.example.yuntiku.dao.impl.ProductDaoImpl;
import com.example.yuntiku.entity.Curriculum;
import com.example.yuntiku.entity.Product;

import java.util.List;

public class ProductService {
    ProductDaoImpl productDao = new ProductDaoImpl();
    public ProductService(){
        this.productDao=new ProductDaoImpl();
    }

    public List<Product> getProducts(){
        List<Product> list = productDao.selectAll();
        for (Product curriculum : list) {
            List<Product> list1 = productDao.selectZji(curriculum.getPtype());
            for (Product curriculum1 : list1) {
                List<Product> list2 = productDao.selectZji(curriculum1.getPtype());
                curriculum1.setChildren(list2);
            }
            curriculum.setChildren(list1);
        }
        return list;
    }

}
